package demoMod.stsconsole.monsters.exordium;

import demoMod.stsconsole.helpers.DamageInfo;
import demoMod.stsconsole.monsters.AbstractMonster;
import demoMod.stsconsole.powers.DexterityPower;
import demoMod.stsconsole.powers.MetallicizePower;
import demoMod.stsconsole.powers.StrengthPower;

public class Lagavulin extends AbstractMonster {
    public static final String ID = "Lagavulin";

    public Lagavulin(boolean isSleeping) {
        super(ID);
        setHp(109, 115);
        this.damage.add(new DamageInfo(20, this));
        this.type = EnemyType.ELITE;
        this.firstMove = isSleeping;
    }

    @Override
    public void usePreBattleAction() {
        if (this.firstMove) {
            this.applyPower(this, new MetallicizePower(this, 8));
            this.gainBlock(8);
        }
    }

    @Override
    public void damage(DamageInfo info) {
        super.damage(info);
        if (this.lastDamageTaken > 0 && lastMove(0)) {
            awake();
        }
    }

    private void awake() {
        changeMove(3, Intent.STUNNED, "", false, 0, null);
        this.applyPower(this, new MetallicizePower(this, -8));
        if (this.getPower(MetallicizePower.ID).amount[0] <= 0) {
            this.removePower(MetallicizePower.ID);
        }
    }

    @Override
    protected void getMove(int aiRng) {
        if (this.firstMove) {
            setMove(0, Intent.SLEEPING);
            firstMove = false;
        } else if (lastMove(0) && !lastTwoMoves(0)) {
            setMove(0, Intent.SLEEPING);
        } else {
            if (!lastTwoMoves(1)) {
                setMove(1, Intent.ATTACK, this.damage.get(0));
            } else {
                setMove(2, Intent.STRONG_DEBUFF, this.monsterStrings.get(1));
            }
        }
    }

    @Override
    public void takeTurn() {
        switch (this.nextMove) {
            case 0:
                this.talk("...");
                if (lastTwoMoves(0)) {
                    awake();
                }
                break;
            case 1:
                this.defaultTarget.damage(this.damage.get(0));
                break;
            case 2:
                this.defaultTarget.applyPower(this, new StrengthPower(this.defaultTarget, -2));
                this.defaultTarget.applyPower(this, new DexterityPower(this.defaultTarget, -2));
                break;
            case 3:
                this.talk("...\n ??? !!!");
                break;
        }
        getMove(0);
    }
}
